<template>
  <div>
    <el-dialog title="批量添加" :visible.sync="open">
      <el-form :model="form" label-width="80px">
        <el-form-item label="活动名称">
          <file-upload ref="fileUpload"
                       :limit="1"
                       :fileSize="5"
                       :fileType="['xls']"
                       @input="handleInput"
          ></file-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="open = false">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import FileUpload from '@/components/FileUpload';
  import {uploadClues} from "@/api/crm/clue";

  export default {
    name: "batch-add",
    components: {FileUpload},
    data() {
      return {
        open: false,
        form: {
          filename: '',
        },
      }
    },
    methods: {
      // 批量添加
      handleInput(filenames) {
        this.form.filename = filenames;
      },
      submitForm() {
        uploadClues(this.form).then(() => {
          // this.$refs.fileUpload.clearFiles();
          this.$message.success('操作成功！');
          this.open = false;
          this.$emit('success');
        });
      },
      // 重置表单
      // resetForm() {
      //   this.form = {
      //     filename: '',
      //   }
      // },
    }
  }
</script>

<style scoped>

</style>
